package chat;

import java.io.ObjectInputStream;
import java.net.Socket;

import javax.swing.JTextArea;

public class ReceiveThread implements Runnable {
	private Socket socket;
	private JTextArea txtArea;

	public ReceiveThread(Socket socket, JTextArea txtArea) {
		this.socket = socket;
		this.txtArea = txtArea;
	}

	@Override
	public void run() {
		ObjectInputStream ois;
		try {
			
			while(true){
				ois = new ObjectInputStream(socket.getInputStream());
				String o=(String)ois.readObject();
				txtArea.append(o+"\n");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}
